package com.zw.log.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zw.log.service.SysLoginLogService;
import com.zw.object.result.Result;
import com.zw.object.system.SysLoginLog;
import com.zw.object.vo.LogLoginVo;
import com.zw.object.vo.SysLoginLogQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * <p>
 * 系统访问记录 前端控制器
 * </p>
 *
 * @author zw
 * @since 2022-12-13
 */
@Api(tags = "日志登录接口")
@RestController
@RequestMapping("/admin/system/logLogin")
public class SysLoginLogController {

    @Autowired
    private SysLoginLogService sysLoginLogService;

    /**
     *                  用于异步记录登录日志接口
     * @param loginVo   参数实体类
     */
    @ApiOperation("用户登录日志记录")
    @PostMapping("/feignLogLogin")
    public void AsyncLoginLogSave(@RequestBody LogLoginVo loginVo){
        sysLoginLogService.asyncLoginLogSave(loginVo);
    }

    /**
     *                              分页获取登录日志信息接口
     * @param page                  当前页码
     * @param limit                 当前页显示数量
     * @param sysLoginLogQueryVo    请求参数实体类
     * @return                      Result
     */
    @ApiOperation("分页获取登录日志信息接口")
    @PostMapping("/{page}/{limit}")
    public Result loginLogListPage(@PathVariable("page")Long page,
                              @PathVariable("limit")Long limit,
                              @RequestBody SysLoginLogQueryVo sysLoginLogQueryVo){
        IPage<SysLoginLog> iPage = new Page<>(page,limit);
        return sysLoginLogService.selectListPage(iPage,sysLoginLogQueryVo);
    }
}

